const fs = require('fs');
const readLine = require('readline');
const path = require('path');
console.time('end');
let count = 0;

function getAllFile() {
    const fileList = (() => {
        const cssFileList = fs.readdirSync(path.resolve(__dirname, '../css')).map(file => {
            return `css\\${file}`;
        });
        const htmlFileList = fs.readdirSync(path.resolve(__dirname, '../html')).map(file => {
            return `html\\${file}`;
        });
        const scriptFileList = fs.readdirSync(path.resolve(__dirname, '../script')).map(file => {
            return `script\\${file}`;
        });
        const l = cssFileList;
        l.push(...htmlFileList);
        l.push(...scriptFileList);
        return l;
    })();
    fileList.forEach(file => {
        const cFile = path.resolve(__dirname, '..', file);
        const rs = fs.createReadStream(cFile);
        const rl = readLine.createInterface({
            input: rs,
        });
        rl.on('line', () => {
            count++;
        });
    });
}

getAllFile();

process.on('exit', () => {
    console.timeEnd('end');
    console.log(count, '行');
});
